package studyNote.test;

public enum EnumDeng {
    GREEN("绿灯") {
        public EnumDeng next() {
            return YELLOW;
        }
    },
    RED("红灯") {
        @Override
        public EnumDeng next() {
            return GREEN;
        }
    },
    YELLOW("黄灯") {
        @Override
        public EnumDeng next() {
            return RED;
        }
    };

    EnumDeng(String description) {}

    public abstract EnumDeng next();

    public static void main(String[] args) throws InterruptedException {
        EnumDeng[] dengs = EnumDeng.values();
        for (int i = 0; i < 3; i++) {
            if (dengs[i] == EnumDeng.GREEN) {
                System.out.println("绿灯行，3秒后是");
                Thread.sleep(3000);
                System.out.println(GREEN.next());
            } else if (dengs[i] == EnumDeng.RED) {
                System.out.println("红灯停，5秒后是");
                Thread.sleep(5000);
                System.out.println(RED.next());
            } else {
                System.out.println("黄灯等一等，2秒后是");
                Thread.sleep(2000);
                System.out.println(YELLOW.next());
            }
        }
    }

}
